package test.wk.net.heartbeat.handler;

import com.wk.net.heartbeat.handler.HeartbeatHandler;
import com.wk.net.heartbeat.handler.listeners.console.ConsoleAbsenceListener;
import com.wk.net.heartbeat.handler.listeners.console.ConsoleHeartbeatListener;
import com.wk.net.heartbeat.handler.receivers.FixedReceiver;
import com.wk.net.heartbeat.heartbeats.fixed.FixedHeartbeat;
import com.wk.net.heartbeat.heartbeats.fixed.FixedHeartbeatTransferer;

public class DemoHeartbeatHandler_mockSource {

	public static void main(String[] args) {
		final String SOURCE = "我";
		final String CONTENT = "心跳";
		final long DELAY = 1500;// 每隔多久模拟一个心跳（单位：毫秒）
		final int CHECK_PERIOD = 1;//检查心跳包的周期（单位：秒）
		final int ABSENCE_TOLERANCE = 5;

		HeartbeatHandler<FixedHeartbeat> handler = new HeartbeatHandler<>(new FixedHeartbeatTransferer(),
				new FixedReceiver(SOURCE, CONTENT, DELAY), CHECK_PERIOD, ABSENCE_TOLERANCE);
		
		handler.setHeartbeatListener(new ConsoleHeartbeatListener<>(new FixedHeartbeatTransferer()));
		handler.setAbsenceListener(new ConsoleAbsenceListener());
		
		handler.start();
	}

}
